/****************************************************************************/
/*  File:       InstallPackage.java                                         */
/*  Author:     F. Georges                                                  */
/*  Company:    H2O Consulting                                              */
/*  Date:       2009-11-02                                                  */
/*  Tags:                                                                   */
/*      Copyright (c) 2009 Florent Georges (see end of file.)               */
/* ------------------------------------------------------------------------ */


package functional.run;

import java.io.File;
import org.expath.pkg.repo.PackageException;
import org.expath.pkg.repo.Repository;
import org.expath.pkg.repo.UserInteractionStrategy;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * ...
 *
 * @author Florent Georges
 * @date   2009-11-02
 */
public class InstallPackage
{
    @Test
    public void test_install()
            throws PackageException
    {
        Repository repo = new Repository(new File(TMP_REPO));
        File       pkg  = new File(HELLO_XAR);
        repo.installPackage(pkg, true, new FakeInteract());
    }

    private static class FakeInteract
            implements UserInteractionStrategy
    {
        public void messageInfo(String msg) throws PackageException {
            System.out.println("INFO: " + msg);
        }
        public void messageError(String msg) throws PackageException {
            System.out.println("ERROR: " + msg);
        }
        public void logInfo(String msg) throws PackageException {
            System.out.println("LOG: " + msg);
        }
        public boolean ask(String prompt, boolean dflt) throws PackageException {
            System.out.println("ASK: " + prompt + " / " + dflt);
            return dflt;
        }
        public String ask(String prompt, String dflt) throws PackageException {
            System.out.println("ASK: " + prompt + " / " + dflt);
            return dflt;
        }
    }

    private static final String HELLO_XAR = "../../misc/hello-pkg/hello-1.0.xar";
    private static final String TMP_REPO  = "../../tmp/repo";
}


/* ------------------------------------------------------------------------ */
/*  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT.               */
/*                                                                          */
/*  The contents of this file are subject to the Mozilla Public License     */
/*  Version 1.0 (the "License"); you may not use this file except in        */
/*  compliance with the License. You may obtain a copy of the License at    */
/*  http://www.mozilla.org/MPL/.                                            */
/*                                                                          */
/*  Software distributed under the License is distributed on an "AS IS"     */
/*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See    */
/*  the License for the specific language governing rights and limitations  */
/*  under the License.                                                      */
/*                                                                          */
/*  The Original Code is: all this file.                                    */
/*                                                                          */
/*  The Initial Developer of the Original Code is Florent Georges.          */
/*                                                                          */
/*  Contributor(s): none.                                                   */
/* ------------------------------------------------------------------------ */
